<template>
  <div>
    <h2>添加</h2>
    <table class="table table-bordered">
      <tbody class="bg gb-primary">
        <tr>
          <td>姓名</td>
          <td>
            <input type="text" v-model="form.name" />
          </td>
        </tr>
        <tr>
          <td>等级</td>
          <td>
            <select v-model="form.dengji">
              <option value="">请选择</option>
              <option>青铜会员</option>
              <option>白银会员</option>
              <option>黄金会员</option>
            </select>
          </td>
        </tr>
        <tr>
          <td>标题</td>
          <td>
            <input type="text" v-model="form.biaoti" />
          </td>
        </tr>
        <tr>
          <td>卡号</td>
          <td>
            <input type="text" v-model="form.kahao" />
          </td>
        </tr>
        <tr>
          <td>手机号</td>
          <td>
            <input type="text" v-model="form.phone" />
          </td>
        </tr>
        <tr>
          <td>余额</td>
          <td>
            <input type="text" v-model="form.yuer" />
          </td>
        </tr>
        <tr>
          <td>积分</td>
          <td>
            <input type="text" v-model="form.jifen" />
          </td>
        </tr>
        <tr>
          <td>消费</td>
          <td>
            <input type="text" v-model="form.xiaofei" />
          </td>
        </tr>
        <tr>
          <td>地址</td>
          <td>
            <input type="text" v-model="form.adder" />
          </td>
        </tr>
        <tr>
          <td></td>
          <td>
            <button @click="Add">添加</button>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</template>

<script setup lang="ts">
import axios from "axios";
import { onMounted, reactive, ref } from "vue";
import { useRouter } from "vue-router";


const router = useRouter();
const form: any = reactive({
  id: 0,
  name: "",
  dengji: "",
  biaoti: "",
  kahao: "",
  phone: "",
  yuer: "",
  jifen: "",
  xiaofei: "",
  adder: "",
});
const Add=()=>{
    if(!form.name){
        alert("姓名不能为空");
        return;
    }

    axios.post("https://localhost:7135/api/User/AddUser",form).then(res=>{
        if(res.data>0){
            alert("添加成功");
            router.push("showuser");
        }
        else
        {
            alert("添加失败");
            return;
        }
    })
}

</script>

<style scoped></style>
